﻿using System.Collections.Generic;
using System.IO;
using ExcelAutomator.Configuration;
using NUnit.Framework;

namespace ExcelAutomator.Tests.IntegrationTests.RangeExecutors
{
	[TestFixture]
	public class MacroRunTestFixture : ExcelTestFixtureBase
	{

		#region RunMacro_WithinInputWorkbook
		[Test]
		public void RunMacro_WithinInputWorkbook()
		{
			var macroCfg = new MacroConfiguration()
			               	{
												ActionId = "run", 
												ExecutionContext = ExecutionContextConfiguration.InputWorkbook, 
												Name = "PrintFooBar"
											};

			var cfg = new ExcelAutomatorConfiguration()
			          	{
			          		Settings = new SettingsConfiguration()
			          		           	{
			          		           		Input = @"Input\" + SourceWbMacroName
			          		           	},
			          		ExecutionSets =
			          			new List<ExecutionSetConfiguration>()
			          				{
			          					new ExecutionSetConfiguration()
			          						{
			          							Id = "My Execution Set",
			          							Executors =
			          								new List<ExecutorConfigurationWrapper>()
			          									{new ExecutorConfigurationWrapper("macro", Constants.ExecutorExtensionsNamespace, macroCfg)}
			          						}
			          				}
			          	};
			var sut = new ExcelAutomationService(cfg);

			sut.ExecuteAutomation();

			base.StartExcel();
			ResolveRangeValues(Path.Combine(InputFolderPath, SourceWbMacroName), "Sheet2", "A1", a1 => Assert.That(a1, Is.EqualTo("FooBar")));
			base.QuitExcel();

		}
		#endregion
		


	}
}
